using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class MPUIMgr : MonoBehaviour
{
    public Image[] _frames;
    public Image[] _content;
    private Canvas _canvas;
    private PropModule _PM;

    private void Start() { }

    private void Update() { }

    public void IniDspl(PropModule UIPM)
    {
        _canvas = GetComponent<Canvas>();
        _PM = UIPM;
    }

    public void Dspl() { _canvas.enabled = true; }
    public void Close() { _canvas.enabled = false; }

    public void Rfr()
    {
        for (int i = 0; i < _PM.CurMPSlot; i++)
        {
            _frames[i].enabled = true;
            _content[i].enabled = true;
            _content[i].fillAmount = i < _PM.ChargedMPSlot ? 1 : 0;
        }

        for (int i = _PM.CurMPSlot; i < _frames.Length; i++)
        {
            _frames[i].enabled = false;
            _content[i].enabled = false;
        }

        if (_PM.RemainingMP > 0) _content[_PM.ChargedMPSlot].fillAmount = 1f * _PM.RemainingMP / _PM.MPPerSlot;
    }
}
